You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
617 B
16 lines
617 B
import { getPublicPostByPublicSlugAndSlug } from "#server/service/posts";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const publicSlug = event.context.params?.publicSlug;
|
|
const postSlug = event.context.params?.postSlug;
|
|
if (!publicSlug || !postSlug || typeof publicSlug !== "string" || typeof postSlug !== "string") {
|
|
throw createError({ statusCode: 400, statusMessage: "无效请求" });
|
|
}
|
|
|
|
const post = await getPublicPostByPublicSlugAndSlug(publicSlug, postSlug);
|
|
if (!post) {
|
|
throw createError({ statusCode: 404, statusMessage: "未找到" });
|
|
}
|
|
|
|
return R.success({ post });
|
|
});
|
|
|